/**
 * 2024.2.8 第八课 继承多态
 */

//包：为了更好的组织和管理 类
class Animal {
    public String name;//访问修饰限定符，只能决定访问权限，不能决定能不能被继承
    public int age;

    static {
        System.out.println("Animal::static{静态}");
    }
    {
        System.out.println("Animal::{实例}");
    }

    public Animal(String name,int age){
        this.name = name;
        this.age = age;
        System.out.println("Animal(String name,int age)");
    }
    /*public Animal(){

    }*/ //默认
    public void eat() {
        System.out.println(this.name + "正在吃饭！");
    }
}
// extends 拓展
class Dog extends Animal {//Dog 子类   Animal  父类
        /*public Dog(){
            super();
        }*/ //默认

       /* public Dog(){
            super("圆圆",10);// 只能在第一行，且只能有一个
        }*/

    static {
        System.out.println("Dog::static{静态}");
    }
    {
        System.out.println("Dog::{实例}");
    }
    public  Dog(String name,int age){
        super(name,age);//调用父类的构造方法，帮助初始化，子类从父类继承过来的成员
        System.out.println("Dog(String name,int age)");
    }
    public void bark() {
        System.out.println(this.name + "正在汪汪叫！");
    }
}
class Cat extends Animal {
    public Cat(String name, int age) {
        super(name, age);
        System.out.println("Cat(String name,int age)");
    }
    public void miaomiao() {
        System.out.println(this.name + "正在喵喵叫！");
    }
}
public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog("圆圆",10);
        System.out.println("=======");
        Dog dog2 = new Dog("圆圆",10);
    }
    public static void main1(String[] args) {
        Dog dog = new Dog("圆圆",10);
        dog.bark();
        dog.eat();
        System.out.println("===========");
        Cat cat = new Cat("mimi",9);
        cat.miaomiao();
        cat.eat();
    }
}